package com.kpx.app.base;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.kpx.app.bean.LoginUser;

/**
 * Created by Administrator on 2016/12/19.
 */
public abstract class FragmentBase extends Fragment {

    public static LoginUser loginUser;
    public LinearLayout rootView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return rootView = (LinearLayout) inflater.inflate(setLayout(), container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    public void showLoadingDialog(Activity activity) {
        if (activity instanceof ActivityBase) {
            ((ActivityBase) activity).showLoadingDialog();
        }
    }

    public void showLoadingPg(Activity activity, String str) {
        if (activity instanceof ActivityBase) {
            ((ActivityBase) activity).showLoadingDialog(str);
        }
    }

    public void showLoadingPg(Activity activity, boolean b) {
        if (activity instanceof ActivityBase) {
            ((ActivityBase) activity).showLoadingDialog(b);
        }
    }
    public void dissmissLoadingDialog(Activity activity) {
        if (activity instanceof ActivityBase) {
            ((ActivityBase) activity).dissmissLoadingDialog();
        }
    }

    /**
     * 设置主体布局
     * @return
     */
    public abstract int setLayout();
}
